package com.hcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hcs.dto.DishUpdateDto;
import com.hcs.entity.Dish;
import com.hcs.mapper.DishMapper;
import com.hcs.service.IDishService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hcs
 * @since 2025-01-12 10:06
 */
@Service
public class DishServiceImpl extends ServiceImpl<DishMapper, Dish> implements IDishService {


    @Override
    public List<Dish> getAllDishes() {
        QueryWrapper<Dish> queryWrapper = new QueryWrapper<>();
        return this.list(queryWrapper);
    }

    @Override
    public List<Dish> getDishListByName(String name) {
        QueryWrapper<Dish> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("name", name);
        return this.list(queryWrapper);
    }

    @Override
    public void addDish(Dish dish) {
        this.save(dish);
    }

    @Override
    public void updateDish(Dish dish) {
        this.updateById(dish);
    }

    @Override
    public void deleteDish(Long dishId) {
        this.removeById(dishId);
    }
}
